package ca.qc.bdeb.info.pp2.tp2.controleur;

import ca.qc.bdeb.info.pp2.tp2.application.ContacterAgentBean;
import ca.qc.bdeb.info.pp2.tp2.application.Facade;
import javax.servlet.http.HttpServletRequest;

public class CommandeContacterAgent implements Commande
{
    private String next;

    public CommandeContacterAgent(String next)
    {
        this.next = next.toLowerCase();
    }

    @Override
    public String executer(HttpServletRequest req) throws CommandeException
    {
        Facade f = new Facade();
        ContacterAgentBean cabean = new ContacterAgentBean();

        cabean.setId_agent(Integer.parseInt(req.getParameter(ConstantesWeb.VALEUR_ID_AGENT)));
        cabean.setPrenom(req.getParameter("prenom"));
        cabean.setNom(req.getParameter("nom"));
        cabean.setNumero_telephone(req.getParameter("numero"));
        cabean.setCourriel(req.getParameter("courriel"));
        cabean.setCommentaire(req.getParameter("commentaire"));

        f.setContacterAgent(cabean);
        return next;
    }
}
